﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace DividendKPI_Proto_1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            //we need to save the contents to the database

            //int user_id = (int)Session["UserId"];
            //Basic INSERT method with Parameters
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
            SqlCommand sqlComm = new SqlCommand();
            sqlComm = sqlConn.CreateCommand();
            sqlComm.CommandText = @"INSERT INTO KPI (DESCRIPTION, COMMENT) VALUES (@KPI_DESCRIPTION,@KPI_COMMENT)";
            sqlComm.Parameters.Add("@KPI_DESCRIPTION", SqlDbType.VarChar);
            sqlComm.Parameters["@KPI_DESCRIPTION"].Value = txtBoxDescription.Text;
            sqlComm.Parameters.Add("@KPI_COMMENT", SqlDbType.VarChar);
            sqlComm.Parameters["@KPI_COMMENT"].Value = txtBoxComment.Text;
            sqlConn.Open();
            sqlComm.ExecuteNonQuery();
            sqlConn.Close();
        }

        public DataTable LoadDataTable()
        {
            string DataBase = "server=Sharp-Coders.Com\\SQLEXPRESS;UID=sa;password=sa;database=MyDatabase";
            string query = "Select * from User_Menu";
            DataTable dataTable = new DataTable();
            SqlDataAdapter dAdapter = new SqlDataAdapter(query, DataBase);
            dAdapter.Fill(dataTable);
            return dataTable;
        }
    }
}